import { AxiosResponse } from 'axios'
import { IException } from './index'

function createError(response: AxiosResponse) : IException {
  return {
    config: response.config,
    code: response?.data?.code || -1,
    errorType: 'serviceError',
    isAxiosError: false,
    request: response.request,
    response,
    toJSON: () => ({
    }),
    name: 'serviceError',
    message: response?.data?.error || '服务异常'
  }
}

export default createError
